package io.lckgroup.modules.lck.controller.wxmp;

import io.lckgroup.common.utils.R;
import io.lckgroup.modules.lck.entity.CommonAdEntity;
import io.lckgroup.modules.lck.entity.ShopMerchantInfoEntity;
import io.lckgroup.modules.lck.service.ShopMerchantInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author huangrui
 */
@RestController
@RequestMapping("/mp/merchantinfo")
@Api(value="微信用户商家controller",tags={"微信用户商家"})
public class MerchantInfoController {
    @Autowired
    private ShopMerchantInfoService shopMerchantInfoService;


    @GetMapping("/weixinMerchantinfo")
    public R getMerchantInfo(Long merchantId) {
        System.out.println(merchantId);
        ShopMerchantInfoEntity infoEntity = new ShopMerchantInfoEntity();
        infoEntity.setId(merchantId);
        ShopMerchantInfoEntity merchantinfo = shopMerchantInfoService.getMerchantinfo(infoEntity);
        return R.ok().put("data", merchantinfo);
    }

    /**
     * 获取首页图片
     *
     * @return
     */
    @GetMapping("getAd")
    public R getAd() {
        CommonAdEntity commonAdEntity = shopMerchantInfoService.getAd();
        return R.ok().put("result", commonAdEntity);
    }

    @ApiOperation(value = "查询所有商家")
    @GetMapping("getAllMerchantInfo")
    public R  getAllMerchantInfo(){
        List<ShopMerchantInfoEntity> info = shopMerchantInfoService.getAllMerchantInfo();
        if(info.size()>0){
            return R.ok().put("data",info);
        }
        return R.error("查询失败");
    }
}
